package icedot.library.common.map;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;


public class ThirdLocationListener 
{
	public List<WeakReference<ThirdLocationNotify> >  _notifyList;

	public ThirdLocationListener()
	{
		_notifyList = new ArrayList<WeakReference<ThirdLocationNotify>>();
	}
	
	public void addNotify(ThirdLocationNotify notify)
	{
		if(notify == null)
			return;
		for(int i = 0; i < _notifyList.size();i++)
		{
			WeakReference<ThirdLocationNotify> wf = _notifyList.get(i);
			ThirdLocationNotify f = wf.get();
			if(f == notify)
				return;
		}
		
		WeakReference<ThirdLocationNotify> nf = new WeakReference<ThirdLocationNotify>(notify);
		_notifyList.add(nf);
	}
	
	public void removeNotify(ThirdLocationNotify notify)
	{
		for(int i = 0; i < _notifyList.size();i++)
		{
			WeakReference<ThirdLocationNotify> wf = _notifyList.get(i);
			ThirdLocationNotify f = wf.get();
			if(f == null || f == notify)
			{
				_notifyList.remove(i);
				return;
			}
		}
	}
	
	public int getNotifySize()
	{
		return _notifyList.size();
	}
}
